"use strict";
let paramHelper = require('./param-helper');

let obj = {
    website: require("../website"),
};

module.exports = async function (req, res, next) {
    try {
        let way = req.body.way;
        let action = req.body.action||'';

        if (!req.session.admin) {
            return res.json({
                result: '未登录或登录超时' + way + action,
                msg: 'unlogin'
            });
        }
        paramHelper(req);
        let o = obj[way];
        if (o) {
            o(req, res, next);
            return false;
        }
        res.json({
            result: 'way未定义:' + way,
            msg: 'fail'
        });
    } catch (e) {
        next(e);
    }
}
